//
//  CXMainViewController.swift
//  Sweibo
//
//  Created by 陈旭 on 16/6/23.
//  Copyright © 2016年 陈旭. All rights reserved.
//

import UIKit

class CXMainViewController: UITabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()

        let tabBar = CXTabBar()
        tabBar.CXDelegate = self
        setValue(tabBar, forKey: "tabBar")
        
        addChildViewController(CXHomeTableViewController(),title: "首页",imgNamed: "tabbar_home")
        addChildViewController(CXMessageController(),title: "消息",imgNamed: "tabbar_message_center")
        addChildViewController(CXDiscoverController(),title: "发现",imgNamed: "tabbar_discover")
        addChildViewController(CXProfileController(),title: "我",imgNamed: "tabbar_profile")
    }
    func addChildViewController(vc:UIViewController,title:String,imgNamed:String) {
        vc.title = title
        vc.tabBarItem.image = UIImage(named: imgNamed)
        vc.tabBarItem.selectedImage = UIImage(named :"\(imgNamed)_selected")
        let navC = UINavigationController(rootViewController: vc)
        addChildViewController(navC)
    }
}
extension CXMainViewController: CXTabBarDelegale{
    func composeButtonClick() {
        print("弹出控制器")
    }
}